#include "timerManager.h"

int
timerManager::setInstance(HINSTANCE hInstance)
{
	m_hInstance = hInstance;
	return 0;
}

HINSTANCE
timerManager::getInstance()
{
	return m_hInstance;
}

int timerManager::setTimer(HWND hwnd, unsigned int uElapse, baseTimer *pTimer)
{
	pTimer->setTimer(hwnd, timerID::Get(), uElapse);
	m_list.push_back(pTimer);
	return 0;
}

int timerManager::onTimer(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	for (THISLIST::iterator iter = m_list.begin(); iter != m_list.end(); ++ iter){
		if (NULL != (*iter)){
			if (hwnd == (*iter)->getHwnd() && wParam == (*iter)->getID()){
				(*iter)->onTimer(hwnd, message, wParam, lParam);		
			}
		}
	}
	return 0;
}